/*=========================================================================
The Impact of Denying a Wanted Abortion on Women and Children
Authors: Juliana Londoño-Vélez and Estefanía Saravia

Creation date: January 9th, 2024
--------------------------------------------------------------------------
Table 9 - Impacts on Household Poverty and Welfare Assistance
=========================================================================*/

use "$data/Final_Medellin_SisbenIV.dta", replace

	
global outcomes Estrato_0_1 Grupo_AB Pobreza_Multidimensional Familias_Accion Regimen_Subsidiado Regimen_Contributivo 

	
		
mat a=J(6,4,.)
matrix rownames a =  $outcomes


local i=1
foreach var in $outcomes    {
	sum `var' if Niega==0
	mat 	a[`i',1] = r(mean)

	ivreghdfe `var'         (Niega=Mujer_Ponente)  , abs(oficina#time) cluster(id_juez) savefirst

	mat 	a[`i',2]  = _b[Niega]
	mat 	a[`i',3] = _se[Niega]

	mat 	a[`i',4] =e(N)


		
	local i=`i'+1
	}


	mat lis a

	svmat2 a, rnames(outcome)
	
	drop if outcome==""
	
	rename a1 mean_nondenied
	rename a2 coef_femaleIV
	rename a3 se_femaleIV
	rename a4 N_femaleIV	
	
	
	keep outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	
	order outcome mean_nondenied coef_femaleIV se_femaleIV N_femaleIV
	
	
	export excel using "$output/Tables paper matrices replication.xlsx", sheet("Table 9", modify) 
